package com.ruoyi.wechat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.FacilityType;
import com.ruoyi.wechat.service.IFacilityTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务设施类型表Controller
 * 
 * @author ruoyi
 * @date 2024-10-29
 */
@RestController
@RequestMapping("/wechat/type")
public class FacilityTypeController extends BaseController
{
    @Autowired
    private IFacilityTypeService facilityTypeService;

    /**
     * 查询服务设施类型表列表
     */
    @PreAuthorize("@ss.hasPermi('wechat:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(FacilityType facilityType)
    {
        startPage();
        List<FacilityType> list = facilityTypeService.selectFacilityTypeList(facilityType);
        return getDataTable(list);
    }
    @GetMapping("/getList")
    public AjaxResult getList(){
        return success(facilityTypeService.selectFacilityTypeList(new FacilityType()));
    }

    /**
     * 导出服务设施类型表列表
     */
    @PreAuthorize("@ss.hasPermi('wechat:type:export')")
    @Log(title = "服务设施类型表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FacilityType facilityType)
    {
        List<FacilityType> list = facilityTypeService.selectFacilityTypeList(facilityType);
        ExcelUtil<FacilityType> util = new ExcelUtil<FacilityType>(FacilityType.class);
        util.exportExcel(response, list, "服务设施类型表数据");
    }

    /**
     * 获取服务设施类型表详细信息
     */
    @PreAuthorize("@ss.hasPermi('wechat:type:query')")
    @GetMapping(value = "/{ftId}")
    public AjaxResult getInfo(@PathVariable("ftId") String ftId)
    {
        return success(facilityTypeService.selectFacilityTypeByFtId(ftId));
    }

    /**
     * 新增服务设施类型表
     */
    @PreAuthorize("@ss.hasPermi('wechat:type:add')")
    @Log(title = "服务设施类型表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FacilityType facilityType)
    {
        return success(facilityTypeService.insertFacilityType(facilityType));
    }

    /**
     * 修改服务设施类型表
     */
    @PreAuthorize("@ss.hasPermi('wechat:type:edit')")
    @Log(title = "服务设施类型表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FacilityType facilityType)
    {
        return toAjax(facilityTypeService.updateFacilityType(facilityType));
    }

    /**
     * 删除服务设施类型表
     */
    @PreAuthorize("@ss.hasPermi('wechat:type:remove')")
    @Log(title = "服务设施类型表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ftIds}")
    public AjaxResult remove(@PathVariable String[] ftIds)
    {
        return toAjax(facilityTypeService.deleteFacilityTypeByFtIds(ftIds));
    }
}
